package com.springboot.rabbitmq.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate.ConfirmCallback;
import org.springframework.amqp.rabbit.connection.CorrelationData;

/**
 * @description: 确认消息已发送到交换机(Exchange)
 * 消息发送到 Broker 后触发回调，确认消息是否到达 Broker 服务器，也就是只确认是否正确到达 Exchange 中
 * @author: zyj
 * @create: 2020-11-10 13:28
 **/
@Slf4j
public class MsgSendConfirmCallBack implements ConfirmCallback {

    @Override
    public void confirm(CorrelationData correlationData, boolean ack, String cause) {
        log.info("返回信息：{}" , correlationData);
        if (ack) {
            log.info("ConfirmCallback: 消息发送确认成功");
        } else {
            log.info("ConfirmCallback: 消息发送确认失败:" + cause);
        }

    }
}
